import random
from L2.learning_module import EvolutionaryLearning


POPULATION_NUM = 100

gen_key = ["name", "age", "hobit", "money", "speed", "home"]
GEN_LENGTH = len(gen_key)

name_list = ["peter", "john", "emily", "eva"]
age_list = [x for x in range(101)]
hobit_list = ["badminton", "football", "cook", "sing", "dancing"]
money_list = [x for x in range(10001)]
speed_list = [x for x in range(51)]
home_list = ["home_1", "home_2", "home_3", "home_4", "home_5", "home_6"]
gen_list = [name_list, age_list, home_list, money_list, speed_list, home_list]


def calculate_fitness(x, y, z):
    return x + y + z


if __name__ == '__main__':
    el = EvolutionaryLearning(150)

    # fitness = []
    for i in range(POPULATION_NUM):
        individual = []
        for j in range(GEN_LENGTH):
            individual.append(random.choice(gen_list[j]))
        # fitness.append((i, random.randint(0, 100)))
        fitness = el.get_fitness(calculate_fitness,
                                 *(random.randint(0, 10), random.randint(0, 10), random.randint(0, 10)))
        el.add_to_group(i, individual, fitness)

    # el.set_group_fitness(fitness)

    # el.roulette_wheel_selection(80)
    # el.tournament_selection(3, 80)
    # el.fitness_based_selection(80)

    # el.single_point_crossover(el.group[1], el.group[2])
    # el.two_point_crossover(el.group[1], el.group[2])

    # el.multi_point_crossover(el.group[1], el.group[2], 3)
    # el.uniform_crossover(el.group[1], el.group[2], 0.8)

    el.update_fitness(10, 0.88)

